/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.View;

import com.model.Anggota;
import com.model.Perpustakaan;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.*;

/**
 *
 * @author Roosz.OchyE
 */
public class PanelCariAnggota extends JPanel {

    private JLabel judulLabel;
    private JLabel labelCariNama;
    private JTextField textCariNama;
    private JLabel labelHasil;
    private JTextArea tabelHasil;
    private JButton tombolSearch;
    private JButton tombolExit;

    public PanelCariAnggota() {
        setLayout(null);

        judulLabel = new JLabel("PANEL CARI ANGGOTA");
        judulLabel.setBounds(125, 5, 200, 20);
        add(judulLabel);

        labelCariNama = new JLabel("Nama");
        labelCariNama.setBounds(5, 100, 100, 20);
        add(labelCariNama);

        textCariNama = new JTextField();
        textCariNama.setBounds(110, 100, 200, 20);
        add(textCariNama);

        tombolSearch = new JButton("Search");
        tombolSearch.setBounds(350, 100, 90, 20);
        add(tombolSearch);
        tombolSearch.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                tombolSearchAction();
            }
        });

        labelHasil = new JLabel("Hasil Searching");
        labelHasil.setBounds(10, 150, 100, 20);
        add(labelHasil);

        tabelHasil = new JTextArea();
        tabelHasil.setBounds(120, 190, 200, 100);
        add(tabelHasil);
        Perpustakaan.cariAnggota((textCariNama.getText()));
        tabelHasil.setText(textCariNama.getText());
//        Perpustakaan.bacaFileAnggota();
//        tabelHasil.setText(Perpustakaan.bacaDaftarAnggota());
    }

    public void tombolSearchAction() {
        Anggota ang = new Anggota();
        ang.setNama(textCariNama.getText());
        Perpustakaan.cariAnggota(textCariNama.getText());
    }
}
